package cn.tansanqinger.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class NewFixedThreadPoolDemo {
    public static void main(String[] args) {
        //创建工作线程数为 3 的线程池
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
        for (int i = 0; i <6; i++) {
            fixedThreadPool.execute(() -> {
                System.out.println(Thread.currentThread().getName() );
            });
        }
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        System.out.println("10毫秒后...");
        //关闭线程池
        fixedThreadPool.shutdown();
    }
}
